package com.sheliduan.itlearning.common.domain.mapper;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sheliduan.itlearning.common.domain.dos.ArticleCategoryRelDO;
import com.sheliduan.itlearning.common.domain.dos.ArticleTagRelDO;

/**
 * @author: 断舍离
 * @date: 2025/2/10 10:09
 * @description: 文章课程_标签关联映射接口
 **/
public interface ArticleTagRelMapper extends BaseMapper<ArticleTagRelDO> {

    default int deleteRelByArticleId(Integer articleId) {
        LambdaUpdateWrapper<ArticleTagRelDO> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(ArticleTagRelDO::getArticleId, articleId);
        return delete(wrapper);
    }

    default int updateRelByArticleId(Integer articleId, Integer tagId) {
        LambdaUpdateWrapper<ArticleTagRelDO> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(ArticleTagRelDO::getTagId, tagId);
        wrapper.eq(ArticleTagRelDO::getArticleId, articleId);
        return update(null, wrapper);
    }
}
